{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "#在cmd中输入pip install baidu-aip\n",
    "from aip import AipImageClassify\n",
    "\n",
    "\"\"\" 你的 APPID AK SK \"\"\"\n",
    "APP_ID = '22856804'\n",
    "API_KEY = 'MwWD7mZC0LEAUsIrjVhnwxmC'\n",
    "SECRET_KEY = 'BO03o5GGGMfBKtsGW8mdLB6lZlYvo0Ph'\n",
    "\n",
    "client = AipImageClassify(APP_ID, API_KEY, SECRET_KEY)\n",
    "\n",
    "#https://ai.baidu.com/ai-doc/IMAGERECOGNITION/"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'error_code': 6, 'error_msg': 'No permission to access data'}\n"
     ]
    }
   ],
   "source": [
    "\"\"\" 读取图片 \"\"\"\n",
    "def get_file_content(filePath):\n",
    "    with open(filePath, 'rb') as fp:\n",
    "        return fp.read()\n",
    "\n",
    "image = get_file_content('D:\\pic\\Picture\\pic.jpg')\n",
    "\n",
    "\"\"\" 调用通用物体识别 \"\"\"\n",
    "client.advancedGeneral(image);\n",
    "\n",
    "\"\"\" 如果有可选参数 \"\"\"\n",
    "options = {}\n",
    "options[\"baike_num\"] = 5\n",
    "\n",
    "\"\"\" 带参数调用通用物体识别 \"\"\"\n",
    "print (client.advancedGeneral(image, options))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.6rc1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
